package com.leetroll.api.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.leetroll.api.mapper.MetricMapper;
import com.leetroll.api.mapper.TagMapper;
import com.leetroll.api.service.MetricService;
import com.leetroll.api.service.TagService;
import com.leetroll.common.entity.Metric;
import com.leetroll.common.entity.Tag;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TagServiceImpl extends SuperServiceImpl<TagMapper, Tag> implements TagService {

    @Override
    @Cacheable(cacheNames = "getTagByWord", key = "#word")
    public Tag getByWord(String word) {
        QueryWrapper<Tag> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("word", word);
        return this.getOne(queryWrapper);
    }
}
